package com.lhjmall.common.exception;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import com.lhjmall.common.reponse.Result;

@RestControllerAdvice
public class ExceptionHandle {

	@ExceptionHandler(Exception.class)
    public Result<Object> serverError(Exception exception){
		Result<Object> result=new Result<>();
		result.setCode(400);
		result.setMsg("服务器内部异常");
		result.setData(null);
        return result;
    }

    @ExceptionHandler(CommonException.class)
    public Result<Object> bussionError(CommonException exception){
		Result<Object> result=new Result<>();
		result.setMsg(exception.getMessage());
		result.setCode(exception.getCode());
		result.setData(null);
        return result;
    }

}
